//
//  BaseTabbarController.m
//  SSFS
//
//  Created by Hero on 16/9/22.
//  Copyright © 2016年 Hero. All rights reserved.
//

#import "BaseTabbarController.h"
#import "BaseNavController.h"
#import "HomeViewController.h"
#import "TeachingViewController.h"
#import "WorkViewController.h"
#import "MineViewController.h"
@interface BaseTabbarController ()<UITabBarControllerDelegate>

@end

@implementation BaseTabbarController
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpAllChildViewController];
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0x999999),NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0x1A7BE5),NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
    self.delegate = self;
}


- (void)setUpAllChildViewController{
    HomeViewController *homeVC = [[HomeViewController alloc]init];
    TeachingViewController *teachVC = [[TeachingViewController alloc]init];
    WorkViewController *workVC = [[WorkViewController alloc]init];
    MineViewController *mineVC = [[MineViewController alloc]init];
    [self setUpOneChildViewController:homeVC image:[UIImage imageNamed:@"首页-首页"] selectedImage:[UIImage imageNamed:@"首页2"] title:@"首页" NavTitle:@"智慧校园"];
    [self setUpOneChildViewController:teachVC image:[UIImage imageNamed:@"Page 1"] selectedImage:[UIImage imageNamed:@"Page 3"] title:@"教学" NavTitle:@"智慧教学"];
    [self setUpOneChildViewController:workVC image:[UIImage imageNamed:@"Fill 1"] selectedImage:[UIImage imageNamed:@"Fill 3"] title:@"办公" NavTitle:@"智慧办公"];
    [self setUpOneChildViewController:mineVC image:[UIImage imageNamed:@"我的（灰）"] selectedImage:[UIImage imageNamed:@"Page 7"] title:@"我的" NavTitle:@"我的"];
}

- (void)setUpOneChildViewController:(UIViewController *)viewController image:(UIImage *)image selectedImage:(UIImage *)selectedImage title:(NSString *)title NavTitle:(NSString *)titleNav{
    viewController.tabBarItem.title = title;
    viewController.tabBarItem.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    viewController.tabBarItem.selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    BaseNavController *nav = [[BaseNavController alloc] initWithRootViewController:viewController];
    viewController.navigationItem.title = titleNav;
    [self addChildViewController:nav];
}
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
    
}

@end
